import os
import pandas as pd
import numpy as np
from config import config_database


class ServiceFolder(object):
    def __init__(self):
        pass

    # 效果目录列表
    def list_folders(self):
        path = np.array(pd.read_csv(
            config_database['file_source_path']))[0][1]
        try:
            out = list()
            folderList = os.listdir(path)
            for item in folderList:
                k = os.listdir(os.path.join(path, item))
                out.append({"name": item, "item": k})
            return {"errcode": 200, "errmsg": "ok", "data": out}
        except:
            return {"errcode": 200, "errmsg": "路径错误，导致读取文件夹失败", "data": []}
